//节流
const throttle = (fn, delay) => {
	let flag = true
	return function(...args) { 
		if (!flag) return
		flag = false
		setTimeout(() => {
			fn.apply(this, ...args)
			flag = true
		}, delay);
	}
}
//防抖
const debounce = (fn, delay) => {
	let timer;
	return function(...args) {
		if (timer) {
			clearInterval(timer)
		} else {
			timer = setInterval(() => {
				fn.apply(this, ...args);
			}, delay)
		}
	}
}


export default {
	throttle,
	debounce,
};